//
// Decompiled by Jadx - 526ms
//
package gc;

import android.text.TextUtils;
import androidx.activity.b;
import com.google.gson.Gson;
import de.robv.android.xposed.XposedHelpers;
import dh.a;
import fi.c;
import fi.e;
import fi.w;
import fj.d;
import fn.j;
import fn.y;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import me.plusne.common.Json.JsonHookStatic;
import me.plusne.common.Json.Soul.JsonHomePagePostList;
import me.plusne.common.Json.Soul.SoulUpdate;
import okhttp3.z;
import r.f;
import r.h;

public final class ak implements Runnable {
    public final int a;
    public final List b;

    public ak(int i, List list) {
        this.a = i;
        this.b = list;
    }

    /* JADX WARN: Removed duplicated region for block: B:36:0x00cf  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00eb  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x010e  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x0130  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x0132  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00d1  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00d4  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x00d7  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x00da  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x00dd  */
    /* JADX WARN: Removed duplicated region for block: B:55:0x00e0  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x00e3  */
    @Override
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void run() {
        f fVar;
        String str;
        boolean z;
        String replace;
        String replace2;
        String audioName;
        String str2;
        String str3;
        int i = this.a;
        List<JsonHomePagePostList.DataDTO.PostListDTO> list = this.b;
        boolean z2 = true;
        switch (i) {
            case 0:
                w wVar = new w(y.by.getActivity());
                wVar.bj(e.LIST_ITEM);
                wVar.bg("修改可见范围");
                c cVar = new c();
                cVar.setList(new ArrayList());
                cVar.setTitle("");
                cVar.setGroup(false);
                cVar.setGravity(8388611);
                for (JsonHomePagePostList.DataDTO.PostListDTO postListDTO : list) {
                    if (postListDTO.getAttachments() == null) {
                        audioName = "";
                    } else {
                        audioName = ((JsonHomePagePostList.DataDTO.PostListDTO.AttachmentsDTO) postListDTO.getAttachments().get(0)).getAudioName();
                    }
                    if (!TextUtils.isEmpty(audioName)) {
                        audioName = audioName.replace("\n", "");
                    }
                    String visibility = postListDTO.getVisibility();
                    visibility.getClass();
                    visibility.hashCode();
                    char c = 65535;
                    switch (visibility.hashCode()) {
                        case -1924094359:
                            if (visibility.equals("PUBLIC")) {
                                c = 0;
                            }
                            switch (c) {
                                case 0:
                                    str2 = "广场可见";
                                    break;
                                case 1:
                                    str2 = "仅陌生人可见";
                                    break;
                                case 2:
                                    str2 = "仅话题广场可见";
                                    break;
                                case 3:
                                    str2 = "不给Ta看";
                                    break;
                                case 4:
                                    str2 = "仅主页可见";
                                    break;
                                case 5:
                                    str2 = "仅自己可见";
                                    break;
                                case 6:
                                    str2 = "仅校园吧用户可见";
                                    break;
                                default:
                                    str2 = "";
                                    break;
                            }
                            if (!TextUtils.isEmpty(str2)) {
                                str2 = b.i("<font color='#00AEEF'>[", str2, "]</font> ");
                            }
                            StringBuilder m = b.m(str2, "<font color='#38B549'>[");
                            m.append(postListDTO.getType());
                            m.append("]</font>");
                            m.append(postListDTO.getContent());
                            if (audioName == null) {
                                audioName = "";
                            }
                            m.append(audioName);
                            String sb = m.toString();
                            StringBuilder sb2 = new StringBuilder();
                            sb2.append(h.m(postListDTO.getCreateTime()));
                            if (!TextUtils.isEmpty(postListDTO.getAudioPlayTimes())) {
                                str3 = "";
                            } else {
                                str3 = " - " + postListDTO.getAudioPlayTimes();
                            }
                            sb2.append(str3);
                            String sb3 = sb2.toString();
                            String valueOf = String.valueOf(postListDTO.getId());
                            boolean ch = y.ch("check_" + postListDTO.getId(), false);
                            c.a aVar = new c.a();
                            aVar.setTitle(sb);
                            aVar.setDesc(sb3);
                            aVar.setKey(valueOf);
                            aVar.setSelected(ch);
                            aVar.setSwitch(true);
                            cVar.getList().add(aVar);
                        case -1724718986:
                            if (visibility.equals("STRANGER")) {
                                c = 1;
                            }
                            switch (c) {
                            }
                            if (!TextUtils.isEmpty(str2)) {
                            }
                            StringBuilder m2 = b.m(str2, "<font color='#38B549'>[");
                            m2.append(postListDTO.getType());
                            m2.append("]</font>");
                            m2.append(postListDTO.getContent());
                            if (audioName == null) {
                            }
                            m2.append(audioName);
                            String sb4 = m2.toString();
                            StringBuilder sb22 = new StringBuilder();
                            sb22.append(h.m(postListDTO.getCreateTime()));
                            if (!TextUtils.isEmpty(postListDTO.getAudioPlayTimes())) {
                            }
                            sb22.append(str3);
                            String sb32 = sb22.toString();
                            String valueOf2 = String.valueOf(postListDTO.getId());
                            boolean ch2 = y.ch("check_" + postListDTO.getId(), false);
                            c.a aVar2 = new c.a();
                            aVar2.setTitle(sb4);
                            aVar2.setDesc(sb32);
                            aVar2.setKey(valueOf2);
                            aVar2.setSelected(ch2);
                            aVar2.setSwitch(true);
                            cVar.getList().add(aVar2);
                            break;
                        case 82810:
                            if (visibility.equals("TAG")) {
                                c = 2;
                            }
                            switch (c) {
                            }
                            if (!TextUtils.isEmpty(str2)) {
                            }
                            StringBuilder m22 = b.m(str2, "<font color='#38B549'>[");
                            m22.append(postListDTO.getType());
                            m22.append("]</font>");
                            m22.append(postListDTO.getContent());
                            if (audioName == null) {
                            }
                            m22.append(audioName);
                            String sb42 = m22.toString();
                            StringBuilder sb222 = new StringBuilder();
                            sb222.append(h.m(postListDTO.getCreateTime()));
                            if (!TextUtils.isEmpty(postListDTO.getAudioPlayTimes())) {
                            }
                            sb222.append(str3);
                            String sb322 = sb222.toString();
                            String valueOf22 = String.valueOf(postListDTO.getId());
                            boolean ch22 = y.ch("check_" + postListDTO.getId(), false);
                            c.a aVar22 = new c.a();
                            aVar22.setTitle(sb42);
                            aVar22.setDesc(sb322);
                            aVar22.setKey(valueOf22);
                            aVar22.setSelected(ch22);
                            aVar22.setSwitch(true);
                            cVar.getList().add(aVar22);
                            break;
                        case 63294573:
                            if (visibility.equals("BLOCK")) {
                                c = 3;
                            }
                            switch (c) {
                            }
                            if (!TextUtils.isEmpty(str2)) {
                            }
                            StringBuilder m222 = b.m(str2, "<font color='#38B549'>[");
                            m222.append(postListDTO.getType());
                            m222.append("]</font>");
                            m222.append(postListDTO.getContent());
                            if (audioName == null) {
                            }
                            m222.append(audioName);
                            String sb422 = m222.toString();
                            StringBuilder sb2222 = new StringBuilder();
                            sb2222.append(h.m(postListDTO.getCreateTime()));
                            if (!TextUtils.isEmpty(postListDTO.getAudioPlayTimes())) {
                            }
                            sb2222.append(str3);
                            String sb3222 = sb2222.toString();
                            String valueOf222 = String.valueOf(postListDTO.getId());
                            boolean ch222 = y.ch("check_" + postListDTO.getId(), false);
                            c.a aVar222 = new c.a();
                            aVar222.setTitle(sb422);
                            aVar222.setDesc(sb3222);
                            aVar222.setKey(valueOf222);
                            aVar222.setSelected(ch222);
                            aVar222.setSwitch(true);
                            cVar.getList().add(aVar222);
                            break;
                        case 297254894:
                            if (visibility.equals("HOMEPAGE")) {
                                c = 4;
                            }
                            switch (c) {
                            }
                            if (!TextUtils.isEmpty(str2)) {
                            }
                            StringBuilder m2222 = b.m(str2, "<font color='#38B549'>[");
                            m2222.append(postListDTO.getType());
                            m2222.append("]</font>");
                            m2222.append(postListDTO.getContent());
                            if (audioName == null) {
                            }
                            m2222.append(audioName);
                            String sb4222 = m2222.toString();
                            StringBuilder sb22222 = new StringBuilder();
                            sb22222.append(h.m(postListDTO.getCreateTime()));
                            if (!TextUtils.isEmpty(postListDTO.getAudioPlayTimes())) {
                            }
                            sb22222.append(str3);
                            String sb32222 = sb22222.toString();
                            String valueOf2222 = String.valueOf(postListDTO.getId());
                            boolean ch2222 = y.ch("check_" + postListDTO.getId(), false);
                            c.a aVar2222 = new c.a();
                            aVar2222.setTitle(sb4222);
                            aVar2222.setDesc(sb32222);
                            aVar2222.setKey(valueOf2222);
                            aVar2222.setSelected(ch2222);
                            aVar2222.setSwitch(true);
                            cVar.getList().add(aVar2222);
                            break;
                        case 403485027:
                            if (visibility.equals("PRIVATE")) {
                                c = 5;
                            }
                            switch (c) {
                            }
                            if (!TextUtils.isEmpty(str2)) {
                            }
                            StringBuilder m22222 = b.m(str2, "<font color='#38B549'>[");
                            m22222.append(postListDTO.getType());
                            m22222.append("]</font>");
                            m22222.append(postListDTO.getContent());
                            if (audioName == null) {
                            }
                            m22222.append(audioName);
                            String sb42222 = m22222.toString();
                            StringBuilder sb222222 = new StringBuilder();
                            sb222222.append(h.m(postListDTO.getCreateTime()));
                            if (!TextUtils.isEmpty(postListDTO.getAudioPlayTimes())) {
                            }
                            sb222222.append(str3);
                            String sb322222 = sb222222.toString();
                            String valueOf22222 = String.valueOf(postListDTO.getId());
                            boolean ch22222 = y.ch("check_" + postListDTO.getId(), false);
                            c.a aVar22222 = new c.a();
                            aVar22222.setTitle(sb42222);
                            aVar22222.setDesc(sb322222);
                            aVar22222.setKey(valueOf22222);
                            aVar22222.setSelected(ch22222);
                            aVar22222.setSwitch(true);
                            cVar.getList().add(aVar22222);
                            break;
                        case 1980555487:
                            if (visibility.equals("CAMPUS")) {
                                c = 6;
                            }
                            switch (c) {
                            }
                            if (!TextUtils.isEmpty(str2)) {
                            }
                            StringBuilder m222222 = b.m(str2, "<font color='#38B549'>[");
                            m222222.append(postListDTO.getType());
                            m222222.append("]</font>");
                            m222222.append(postListDTO.getContent());
                            if (audioName == null) {
                            }
                            m222222.append(audioName);
                            String sb422222 = m222222.toString();
                            StringBuilder sb2222222 = new StringBuilder();
                            sb2222222.append(h.m(postListDTO.getCreateTime()));
                            if (!TextUtils.isEmpty(postListDTO.getAudioPlayTimes())) {
                            }
                            sb2222222.append(str3);
                            String sb3222222 = sb2222222.toString();
                            String valueOf222222 = String.valueOf(postListDTO.getId());
                            boolean ch222222 = y.ch("check_" + postListDTO.getId(), false);
                            c.a aVar222222 = new c.a();
                            aVar222222.setTitle(sb422222);
                            aVar222222.setDesc(sb3222222);
                            aVar222222.setKey(valueOf222222);
                            aVar222222.setSelected(ch222222);
                            aVar222222.setSwitch(true);
                            cVar.getList().add(aVar222222);
                            break;
                        default:
                            switch (c) {
                            }
                            if (!TextUtils.isEmpty(str2)) {
                            }
                            StringBuilder m2222222 = b.m(str2, "<font color='#38B549'>[");
                            m2222222.append(postListDTO.getType());
                            m2222222.append("]</font>");
                            m2222222.append(postListDTO.getContent());
                            if (audioName == null) {
                            }
                            m2222222.append(audioName);
                            String sb4222222 = m2222222.toString();
                            StringBuilder sb22222222 = new StringBuilder();
                            sb22222222.append(h.m(postListDTO.getCreateTime()));
                            if (!TextUtils.isEmpty(postListDTO.getAudioPlayTimes())) {
                            }
                            sb22222222.append(str3);
                            String sb32222222 = sb22222222.toString();
                            String valueOf2222222 = String.valueOf(postListDTO.getId());
                            boolean ch2222222 = y.ch("check_" + postListDTO.getId(), false);
                            c.a aVar2222222 = new c.a();
                            aVar2222222.setTitle(sb4222222);
                            aVar2222222.setDesc(sb32222222);
                            aVar2222222.setKey(valueOf2222222);
                            aVar2222222.setSelected(ch2222222);
                            aVar2222222.setSwitch(true);
                            cVar.getList().add(aVar2222222);
                            break;
                    }
                }
                wVar.aq.add(cVar);
                fg.b bVar = wVar.y;
                if (bVar != null) {
                    bVar.notifyItemChanged(r1.size() - 1);
                }
                wVar.v = new me.plusne.Adapter.Login.h(24);
                wVar.ae = new ao();
                wVar.bk();
                return;
            default:
                HashMap hashMap = co.a;
                dg.b bVar2 = new dg.b();
                ArrayList arrayList = new ArrayList();
                String as = j.as(z.ea(), "signature");
                if (list != null) {
                    for (Object obj : list) {
                        if (TextUtils.isEmpty(co.e)) {
                            co.e = y.cn(obj.getClass(), "cn.soulapp.android.client.component.middle.platform.model.api.user.ImUserBean", z2);
                        }
                        Object objectField = XposedHelpers.getObjectField(obj, co.e);
                        if (objectField != null) {
                            String as2 = j.as(objectField, "userIdEcpt");
                            String dm = z.dm(as2);
                            String as3 = j.as(objectField, "signature");
                            SoulUpdate soulUpdate = new SoulUpdate();
                            if (as == null) {
                                replace = "";
                            } else {
                                replace = as.replace("\n", "");
                            }
                            soulUpdate.setMyUser(replace);
                            if (as3 == null) {
                                replace2 = "";
                            } else {
                                replace2 = as3.replace("\n", "");
                            }
                            soulUpdate.setSignature(replace2);
                            soulUpdate.setMyUserId(z.eb());
                            soulUpdate.setUserId(dm);
                            soulUpdate.setAvatarName(j.as(objectField, "avatarName"));
                            soulUpdate.setUserIdEcpt(as2);
                            arrayList.add(soulUpdate);
                            z2 = true;
                        }
                    }
                }
                StringBuilder sb5 = new StringBuilder();
                sb5.append(fn.b.g("backup_host", ""));
                sb5.append("PlusNEBack/PlusNE_");
                JsonHookStatic jsonHookStatic = y.by;
                sb5.append(jsonHookStatic.getPre());
                sb5.append(".ne");
                String sb6 = sb5.toString();
                bVar2.f(fn.b.g("backup_user", ""), fn.b.g("backup_pass", ""));
                try {
                    if (bVar2.c(sb6)) {
                        String str4 = jsonHookStatic.getActivity().getCacheDir() + "/PlusNE_" + jsonHookStatic.getPre() + System.currentTimeMillis() + ".ne";
                        if (d.f(bVar2.d(sb6), str4)) {
                            List<SoulUpdate> list2 = (List) new Gson().fromJson(d.e(str4), new cr().getType());
                            if (list2 != null) {
                                for (SoulUpdate soulUpdate2 : list2) {
                                    Iterator it = arrayList.iterator();
                                    while (true) {
                                        if (it.hasNext()) {
                                            if (((SoulUpdate) it.next()).getUserId().equals(soulUpdate2.getUserId())) {
                                                z = false;
                                            }
                                        } else {
                                            z = true;
                                        }
                                    }
                                    if (z) {
                                        arrayList.add(soulUpdate2);
                                    }
                                }
                            }
                        }
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
                String json = new Gson().toJson(arrayList);
                JsonHookStatic jsonHookStatic2 = y.by;
                new f(jsonHookStatic2.getActivity()).l("正在备份到云端,请稍后....");
                String str5 = jsonHookStatic2.getActivity().getCacheDir() + "/PlusNE_" + jsonHookStatic2.getPre() + System.currentTimeMillis() + ".ne";
                d.g(str5, json);
                try {
                    if (!bVar2.c(fn.b.g("backup_host", "") + "PlusNEBack")) {
                        bVar2.b(fn.b.g("backup_host", "") + "PlusNEBack");
                    }
                    String str6 = fn.b.g("backup_host", "") + "PlusNEBack/PlusNE_" + jsonHookStatic2.getPre() + ".ne";
                    if (bVar2.c(str6)) {
                        z.a aVar3 = new z.a();
                        aVar3.l(str6);
                        aVar3.j("DELETE", l.c.d);
                        a.a(bVar2.a.a(aVar3.g()).execute());
                    }
                    bVar2.e(str6, new File(str5));
                    if (bVar2.c(str6)) {
                        fVar = new f(jsonHookStatic2.getActivity());
                        fVar.n();
                        str = "备份成功";
                    } else {
                        fVar = new f(jsonHookStatic2.getActivity());
                        fVar.j();
                        str = "备份失败";
                    }
                    fVar.l(str);
                } catch (IOException e2) {
                    e2.printStackTrace();
                    b.p(y.by.getActivity()).l("备份失败:" + e2.getMessage() + "\n 请检查参数是否填写正确");
                }
                fi.y.d();
                return;
        }
    }
}
